from flask import Blueprint
from flask import request
from common.R import R
from entry.Entrys import Page
from util.ParamUtil import formatParam
from util import JwtUtil
blu = Blueprint('flask-admin',__name__)
route = blu.route
after = blu.after_request
error = blu.errorhandler
before =blu.before_request
formatParam
R
Page
request
def getUid():
    return JwtUtil.getUserId(request)

def getRid():
    return request.environ.get("RID")

def getUsername():
    return request.environ.get("USERNAME")

# 获取用户真实ip地址
def getUserRemoteAddr():
    ip = request.headers.get('X-Real-IP')
    if ip!= None:
        return ip.replace('::ffff:','').replace('::1','127.0.0.1')
    ip = request.headers.get('X-Forwarded-For')
    if ip!= None:
        return ip.split(', ')[0].replace('::ffff:','').replace('::1','127.0.0.1')
    return request.remote_addr